/*
 * Coder
 *
 *  Created on: 10/06/2011
 *      Author: Agustina I. Stekolschik & Ezequiel Palumbo
 */

#ifndef CODER_H_
#define CODER_H_

#include <AbstractContext.h>
#include <DataUnit.h>
#include <DataInputOutput.h>

using namespace contexts;
using namespace DataInputOutput;

namespace coder{

class Coder{
public:
	Coder(){};
	virtual void encode(ContextUnit& aContextUnit)=0;
	virtual void setDataOutput(BitDataOutput& dataOutput)=0;
	virtual ~Coder(){};
};

class ArithmeticCoder : public Coder{
public:
	ArithmeticCoder();
	void encode(ContextUnit& aContextUnit);
	void setDataOutput(BitDataOutput& dataOutput);
	virtual ~ArithmeticCoder();
protected:
	void encode(const unsigned int low_count, const unsigned int high_count, const unsigned int total);
	void encodeFinish();

	//Handle the output
	BitDataOutput* bitDataOutput;
	//Handle the arithmetic method
	unsigned int lowBound;
	unsigned int topBound;
	unsigned int currStep;
	unsigned int currScale;
};

}
#endif
